package com.anyou.mall.wxrefund.controller;

import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.mall.wxrefund.WechatPayParam;
import com.anyou.mall.wxrefund.WxRefundParam;
import com.anyou.mall.wxrefund.WxRefundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


/**
 * 微信相关Controller
 *
 * @author ylj
 * @date 2022-03-23
 */
@Api(tags = "微信退款相关")
@RestController
@RequestMapping("/wx/ctr")
public class WxPayController extends BaseController {
    @Autowired
    private WxRefundService wxRefundService;




    @ApiOperation("微信退款")
    @PreAuthorize("@ss.hasPermi('wx:ctr:wxRefund')")
    @PostMapping(value = "/wxRefund")
    public ApiResult wxRefund(@Valid @RequestBody WxRefundParam wxRefundParam) {
        return wxRefundService.wxRefund(wxRefundParam);
    }

    @ApiOperation(value = "h5微信支付(统一下单)")
    @PreAuthorize("@ss.hasPermi('wx:ctr:wxPayH5')")
    @PostMapping("/orderPayWx")
    public ApiResult orderPay(@Valid @RequestBody WechatPayParam wechatPayParam, HttpServletRequest request) {
        return wxRefundService.orderPay(wechatPayParam,request);
    }




}
